//
//  FriendService.m
//  TipsProject
//
//  Created by Suny on 15/6/14.
//  Copyright (c) 2015年 Suny. All rights reserved.
//

#import "FriendService.h"
#import "UserInfo.h"
@implementation FriendService
- (void)getFollowFriendByUserId:(NSString *)memberId pageIndex:(NSInteger)pageNumber finishBlock:(RequestFinishBlock)finishBlock
{
	NSDictionary *dictionary = @{@"memberId":memberId,@"curPage":@(pageNumber),@"pageSize":@(kDefaultPageSize)};
	
	WEAKSELF;		
	AFHTTPRequestOperation * requestOperation = [self beginGetRequestWithRelativePath:kGetFriendAttention
																	  parameterObject:dictionary
																		responseClass:nil
																		  finishBlock:^(BaseResponse *response) {
																			  [weakSelf removeWrapperForKey:kGetFriendAttention];
																			  NSMutableArray *array = [NSMutableArray array];
																			  
																			  NSArray *temArray = [response.object objectForKey:@"pageContent"];
																			  for (NSDictionary *dic in temArray)
																			  {
																				  UserInfo *info = [[UserInfo alloc] initWithSourceString:dic];
																				  [array addObject:info];
																			  }
																			  
																			  response.object = array;
																			  
																			  finishBlock(response);
																			  
																		  }];
	[self setWrapper:requestOperation
			  ForKey:kGetFriendAttention];
}


- (void)getFollowedFriendByUserId:(NSString *)memberId pageIndex:(NSInteger)pageNumber finishBlock:(RequestFinishBlock)finishBlock
{
	NSDictionary *dictionary = @{@"memberId":memberId,@"curPage":@(pageNumber),@"pageSize":@(kDefaultPageSize)};
	
	WEAKSELF;		
	AFHTTPRequestOperation * requestOperation = [self beginGetRequestWithRelativePath:kGetFriendAttentioned
																	  parameterObject:dictionary
																		responseClass:nil
																		  finishBlock:^(BaseResponse *response) {
																			  [weakSelf removeWrapperForKey:kGetFriendAttention];
																			  NSMutableArray *array = [NSMutableArray array];
																			  
																			  NSArray *temArray = [response.object objectForKey:@"pageContent"];
																			  for (NSDictionary *dic in temArray)
																			  {
																				  UserInfo *info = [[UserInfo alloc] initWithSourceString:dic];
																				  [array addObject:info];
																			  }
																			  
																			  response.object = array;
																			  
																			  finishBlock(response);
																			  
																		  }];
	[self setWrapper:requestOperation
			  ForKey:kGetFriendAttentioned];
}
@end
